.DATA
EXTERN  g_0EOld:DQ
EXTERN  g_0ENew:DQ
CODE
HOOKOE proc
        push    rbp
        sub     rsp,158h
        lea     rbp,[rsp+80h]
        test    byte ptr [rbp+0F0h],1
        je LabelKernel    
        swapgs
LabelKernel:
      push rax
      push rcx
      push rdx
      push rbx
      push rsi
      push rdi
      push r8
      push r9
      push r10
      push r11
      push r12
      push r13
	  push r14
	  push r15
	  pushfq
	  cli
	  MOV RCX,RSP
	  ADD RCX,78h 

	  SUB RSP,50h
      call g_0ENew
	  add RSP,50h
	  cmp al,1
	  je R3
	  popfq
	  pop r15
	  pop r14
	  pop r13
      pop r12
      pop r11
      pop r10
      pop r9
      pop r8
      pop rdi
      pop rsi
	  pop rbx
	  pop rdx
	  pop rcx
	  pop rax
	  test    byte ptr [rbp+0F0h],1
      je LabelKernelEnd
      swapgs
LabelKernelEnd:
      add  rsp,158h
      pop rbp
	  jmp g_0EOld
R3:
      popfq
	  pop r15
	  pop r14
	  pop r13
      pop r12
      pop r11
      pop r10
      pop r9
      pop r8
      pop rdi
      pop rsi
	  pop rbx
	  pop rdx
	  pop rcx
	  pop rax
      test   byte ptr [rbp+0F0h],1
      je LabelKernelEnd1

      swapgs


 LabelKernelEnd1:
      add rsp,158h
      pop rbp
	  add rsp,8h
	  iretq

HOOKOE endp


END
CODE